package com.heima.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.dtos.SensitiveDto;

import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.user.mapper.SensitiveMapper;
import com.heima.user.service.SensitiveService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class SensitiveServiceImpl extends ServiceImpl<SensitiveMapper, WmSensitive> implements SensitiveService  {
	@Autowired
	private SensitiveMapper sensitiveMapper;
	@Override
	public ResponseResult SensiteveList(SensitiveDto dto) {
		if (dto == null) {
			return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
		}
		LambdaQueryWrapper<WmSensitive> wrapper = new LambdaQueryWrapper<>();
		Integer page = dto.getPage();
		Integer size = dto.getSize();
		String name = dto.getName();
		wrapper.eq(!StringUtils.isEmpty(name),WmSensitive::getSensitives,name);
		Page<WmSensitive> wmSensitivePage = new Page<>(page, size);
		wmSensitivePage = sensitiveMapper.selectPage(wmSensitivePage, wrapper);
		ResponseResult<WmSensitive> result = new ResponseResult<WmSensitive>();
		result.setData(result.getData());
		return result;
	}
}
